<template>
    <div class="index-lists">
        <el-card class="!border-none mt-4" shadow="never">
            <el-table
                class="mt-4"
                size="large"
                v-loading="pager.loading"
                :data="pager.lists"
            >
                <el-table-column label="时间" prop="createTime" min-width="100" />
                <el-table-column label="用户" prop="account" min-width="100" />
                <el-table-column label="内容" prop="content" min-width="100" />
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
        <edit-popup
            v-if="showEdit"
            ref="editRef"
            @success="getLists"
            @close="showEdit = false"
        />
    </div>
</template>
<script lang="ts" setup name="fashi_login_log">
import { fashi_login_logDelete, fashi_login_logLists } from '@/api/fashi_login_log'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
const queryParams = reactive({
    account: '',
    logStatus: '',
    content: '',
})

const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: fashi_login_logLists,
    params: queryParams
})



const handleAdd = async () => {
    showEdit.value = true
    await nextTick()
    editRef.value?.open('add')
}

const handleEdit = async (data: any) => {
    showEdit.value = true
    await nextTick()
    editRef.value?.open('edit')
    editRef.value?.getDetail(data)
}

const handleDelete = async (id: number) => {
    await feedback.confirm('确定要删除？')
    await fashi_login_logDelete({ id })
    feedback.msgSuccess('删除成功')
    getLists()
}

getLists()
</script>
